package com.cn.intelligence.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cn.intelligence.mapper.SalerateMapper;
import com.cn.intelligence.pojo.Salerate;
import com.cn.intelligence.pojo.SalerateExample;
import com.cn.intelligence.service.SalerateService;
@Service
public class SalerateServiceImpl implements SalerateService {

	@Autowired
	SalerateMapper salerateMapper;
	
	/**
	 * 查询有效期的比率
	 */
	@Override
	public Salerate selectByExample() {
		
		SalerateExample salerateExample = new SalerateExample();
		SalerateExample.Criteria criteria = salerateExample.createCriteria();
		// 查询有效期内的数据
		criteria.andActivetimestartLessThanOrEqualTo(new Date());
		criteria.andActivetimeendGreaterThanOrEqualTo(new Date());
		List<Salerate>  salerateList = salerateMapper.selectByExample(salerateExample);
		if(salerateList.size()==0){
			return null;
		}else{
			return salerateList.get(0);
		}
	}
	
}
